package com.licode;

import com.sun.javaws.IconUtil;

import java.util.*;

public class demo {

    public static String s="dcab";
    public static char[] chars = s.toCharArray();
        public static void main(String[] args) {
            List<List<Integer>> pairs = new ArrayList<List<Integer>>();
            pairs.add(Arrays.asList(0,3));
            pairs.add(Arrays.asList(1,2));
            pairs.add(Arrays.asList(0,2));

           /* pairs.add(Arrays.asList(0,1));
            pairs.add(Arrays.asList(1 ,2));*/

            smallestStringWithSwaps(s,pairs);
            for(char c : chars){
                System.out.print(c+" ");
            }
  /*          swap(0,3);
            for(char c : chars){
                System.out.println(c);
            }*/

        }

    public static void smallestStringWithSwaps(String s, List<List<Integer>> pairs) {
            boolean status = false;
            while(true){
                int n = 0;
                for(List<Integer> list : pairs){
                    int first = list.get(0);
                    int last = list.get(1);
                    System.out.println("first="+first+" "+"last="+last);
                    if(chars[first] > chars[last] ){
                        System.out.println("1chars[first]="+chars[first]+" "+"chars[last]="+chars[last]);
                        char c = chars[first];
                        chars[first] = chars[last];
                        chars[last] = c;
                        System.out.println("2chars[first]="+chars[first]+" "+"chars[last]="+chars[last]);
                        n++;
                    }
                }
                for(char c : chars){
                    System.out.print(c+" ");
                }
                System.out.println("n="+n);
                if(n == 0){
                    break;
                }
                }

    }

}
